package co.fitstart.admin.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.demo2do.core.persistence.GenericDaoSupport;
import com.demo2do.core.persistence.annotation.Dynamic;

import co.fitstart.admin.dao.SmsBlackListDao;
import co.fitstart.admin.service.SmsBlackListService;
import co.fitstart.entity.course.SmsBlackList;

/**
 * 
 * @author LZJ
 *
 */
@Service("smsBlackListService")
public class SmsBlackListServiceImpl implements SmsBlackListService {
	
	@Dynamic
	private SmsBlackListDao smsBlackListDao;
	
    @Autowired
    private GenericDaoSupport genericDaoSupport;
	
	/*
	 * (non-Javadoc)
	 * @see co.fitstart.admin.service.SmsBlackListService#changeBlackListStatus(java.lang.String)
	 */
	public void changeBlackList(String mobile) {
		
		
		
		
		SmsBlackList list = smsBlackListDao.loadBlackList(mobile);
		
		if( list == null) {			
			
			SmsBlackList blackList = new SmsBlackList();
			blackList.addMobileInBlackList(mobile);
			genericDaoSupport.save(blackList);
			
		}    
		
	}

	
	/*
	 * (non-Javadoc)
	 * @see co.fitstart.admin.service.SmsBlackListService#deleteBlackList(java.lang.String)
	 */
	public void deleteBlackList(String mobile) {
		
		
		
		SmsBlackList list = smsBlackListDao.loadBlackList(mobile);
		
		if( list != null) {
			
			genericDaoSupport.delete(list);
			
		}    
		
		
	}
	
	
	public boolean  getBlackList(String mobile) {
		
		SmsBlackList list = smsBlackListDao.loadBlackList(mobile);
		
		if(list != null) {
			
			return true;
		}
		
		return false;
	}

	
	
   
}
